<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    div{
        width: 400px;
        height: 400px;
        background: cadetblue;
    }
    span{
        width: 200px;
        height: 200px;
        background: greenyellow;
        display: block;
    }
    </style>
</head>
<body>
    <div>
        <span></span>
    </div>
    <script>
    var div=document.getElementsByTagName("div")[0]
    var span=document.getElementsByTagName("span")[0]
    // div.onmouseover=function(){
    //     console.log("鼠标划入");
    //     div.style.background="red";
    // }
    // div.onmouseout=function(){
    //     console.log("鼠标滑出");
    //     div.style.background="cadetblue";
    // }

    //   div.onmouseenter=function(){
    //     console.log("鼠标划入");
    //     div.style.background="red";
    // }
    // div.onmouseleave=function(){
    //     console.log("鼠标滑出");
    //     div.style.background="cadetblue";
    // }

    div.onmouseup=function(){  //鼠标左键、中建、右键都算
        console.log("鼠标按下");
        div.style.background="red";
    }
    div.onmousemove=function(){  //鼠标在box里面移动就触发
        console.log("鼠标移动");
        div.style.background="red";
    }
    
    div.onmousedown=function(){
        console.log("鼠标抬起");
        div.style.background="cadetblue";
    }


    </script>
</body>
</html>